#include <Ice/Ice.h>
#include <SessionManagerI.h>
#include <SessionManagerServiceI.h>

extern "C"{
  SESSIONMANAGER_API IceBox::Service*
  create(Ice::CommunicatorPtr communicator)
  {
    return new SessionManagerServiceI;
  }
}

void SessionManagerServiceI::start(const std::string& name,
				   const Ice::CommunicatorPtr& communicator,
				   const Ice::StringSeq& args)
{
  Glacier2::SSLSessionManagerPrx manager = Glacier2::SSLSessionManagerPrx::checkedCast
    (communicator->stringToProxy(/*communicator->getProperties()->getProperty("SessionManager")*/
				 "IceGrid/SSLSessionManager"));
  assert(manager);

  _adapter = communicator->createObjectAdapter(name + "-SessionManager");
  _adapter->add(new SessionManagerI(manager),
		communicator->stringToIdentity(name + "-SessionManager"));

  _adapter->activate();
}

void SessionManagerServiceI::stop()
{
  _adapter->deactivate();
}
